package org.mydba.info;

import java.util.Map;

/**
 * Represents an execution context.
 *
 * @since 1.0
 *
 */
public class Execution {
    /** Monitored Oracle session id (SID). */
    private int sid;

    /** MyDBA execution id. */
    private long execId;

    /** Oracle statistics before running the query. */
    private Map<Integer, OracleStatistic> beforeStatistics;

    /** Oracle events before running the query. */
    private Map<Long, OracleEvent> beforeEvents;

    /** Result set statistics. */
    private ResultSetStatistic resultSetStatistic;

    private String preparedStatementQuery;

    private String preparedStatementSQLId;
    private int preparedStatementChildNumber;
    private UpdateStatistic updateStatistic;

    public Execution(final int sid, final long execId, final Map<Integer, OracleStatistic> beforeStatistics, final Map<Long, OracleEvent> beforeEvents) {
        this.sid = sid;
        this.execId = execId;
        assert beforeStatistics != null;
        this.beforeStatistics = beforeStatistics;
        assert beforeEvents != null;
        this.beforeEvents = beforeEvents;
    }

    public Execution(final int sid, final String preparedStatementQuery, final Map<Integer, OracleStatistic> beforeStatistics, final Map<Long, OracleEvent> beforeEvents) {
        this.sid = sid;
        this.preparedStatementQuery = preparedStatementQuery;
        assert beforeStatistics != null;
        this.beforeStatistics = beforeStatistics;
        assert beforeEvents != null;
        this.beforeEvents = beforeEvents;
    }

    public int getSid() {
        return sid;
    }

    public long getExecId() {
        return execId;
    }

    public void setExecId(long execId) {
        this.execId = execId;
    }

    public Map<Integer, OracleStatistic> getBeforeStatistics() {
        return beforeStatistics;
    }

    public Map<Long, OracleEvent> getBeforeEvents() {
        return beforeEvents;
    }

    public ResultSetStatistic getResultSetStatistic() {
        return resultSetStatistic;
    }

    public void setResultSetStatistic(ResultSetStatistic resultSetStatistic) {
        this.resultSetStatistic = resultSetStatistic;
    }

    public String getPreparedStatementQuery() {
        return preparedStatementQuery;
    }

    public String getPreparedStatementSQLId() {
        return preparedStatementSQLId;
    }

    public void setPreparedStatementSQLIdAndChildNumber(String sqlid, int childNumber) {
        this.preparedStatementSQLId = sqlid;
        this.preparedStatementChildNumber = childNumber;
    }

    public int getPreparedStatementChildNumber() {
        return preparedStatementChildNumber;
    }

    public void setUpdateStatistic(UpdateStatistic updateStatistic) {
        this.updateStatistic = updateStatistic;
    }

    public UpdateStatistic getUpdateStatistic() {
        return updateStatistic;
    }
}
